This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from dataclasses import dataclass | |
from typing import ( | |
Any, | |
Callable, | |
Protocol, | |
overload, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from dataclasses import dataclass | |
from typing import ( | |
Any, | |
Callable, | |
Protocol, | |
overload, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from dataclasses import dataclass | |
from typing import ( | |
Any, | |
Protocol, | |
overload, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Iterator | |
def fib(n: int) -> Iterator[int]: | |
a, b = 0, 1 | |
while a < n: | |
yield a | |
a, b = b, a + b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Set | |
class Wizard: | |
def __init__(self, name: str, expert: str, spells: List[int]): | |
self.name = name | |
self.spells = spells | |
self.expert = expert | |
def average_spell_power(self): | |
return sum(self.spells) / len(self.spells) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import List, Set | |
class Wizard: | |
def __init__(self, name, expert, spells): | |
self.name = name | |
self.spells = spells | |
self.expert = expert | |
def average_spell_power(self): | |
return sum(self.spells) / len(self.spells) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Iterator | |
def fib(n: int) -> Iterator[int]: | |
a, b = 0, 1 | |
while a < n: | |
yield a | |
a, b = b, a + b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Never | |
class A: | |
x: int | |
class B: | |
x: str | |
class X(A, B): | |
@property | |
def x(self) -> Never: raise Exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Never | |
class A: | |
def f(self) -> int: return 0 | |
class B: | |
def f(self) -> str: return "" | |
class X(A, B): | |
def f(self) -> Never: raise Exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python implementation of the algorithm from "Lambda-Lifting in Quadratic Time" by Danvy and Schultz | |
from __future__ import annotations | |
import io | |
import sys | |
import types | |
from collections.abc import Mapping | |
from typing import Generic, TypeVar |
NewerOlder